import boto3




# response = client.list_tasks(
#     cluster='ptadmin-automation-ec2',
#     launchType='EC2'
# )
#
# print(response)

class EcsCluster(object):

    def __init__(self, cluster_name):
        self.client = boto3.client('ecs')
        self.cluster_name = cluster_name

    def submit_task(self, task):
        response = self.client.run_task(
            # capacityProviderStrategy=[
            #     {
            #         'capacityProvider': 'string',
            #         'weight': 123,
            #         'base': 123
            #     },
            # ],
            cluster=self.cluster_name,
            count=task.instanceCount,
            # enableECSManagedTags=True|False,
            # group='string',
            launchType=task.launchType,
            networkConfiguration=task.networkConfiguration,
            overrides=task.overrides,
            taskDefinition="%s:%s" % (task.taskDefinition, task.version)
            # placementConstraints=[
            #     {
            #         'type': 'distinctInstance'|'memberOf',
            #         'expression': 'string'
            #     },
            # ],
            # placementStrategy=[
            #     {
            #         'type': 'random'|'spread'|'binpack',
            #         'field': 'string'
            #     },
            # ],
            # platformVersion='string',
            # propagateTags='TASK_DEFINITION'|'SERVICE',
            # referenceId='string',
            # startedBy='string',
            # tags=[
            #     {
            #         'key': 'string',
            #         'value': 'string'
            #     },
            # ],
            # taskDefinition='browse-tree-node-processor-task:9'
        )
        return response
